#include <iostream>
#include <string>
#include <jsoncpp/json/json.h>
#include <unistd.h>

using namespace std;

int main()
{
    Json::Value jv;
    jv["snow"] = "雪";
    jv["dragon"] = "龙";
    Json::StyledWriter w1;

    string str = w1.write(jv);
    cout << str << endl;

    Json::Value root;
    root["data1"] = 10;
    root["data2"] = 20;
    root["oper"] = '+';
    root["jv"] = jv;

    // Json::FastWriter w2;
    Json::StyledWriter w2;
    string str2 = w2.write(root);
    cout << str2 << endl;

    sleep(2);

    Json::Value root2;
    Json::Reader r;
    r.parse(str2, root2);
    int data1 = root2["data1"].asInt();
    int data2 = root2["data2"].asInt();
    char oper = root2["oper"].asInt();
    Json::Value tmp = root2["jv"];

    cout << data1 << "\n";
    cout << data2 << "\n";
    cout << oper << "\n";
    cout << tmp << "\n";

    return 0;
}
